

local POS_Y_1 =  172

local ORDERS =
{
    {"curse",       { 0,     POS_Y_1 }},
}

local MID_X = 2
local MID_Y = 90


local TOP1 = 40
local DOW1 = -40
local LIF1 = -40
local RIG1 = 40

local lockd = 20

local DOF1 = -40

local function BuildSkillsData(SkillTreeFns)
    local skills = {
        --
            i26_skill1 = {
                title = '剑为地纪，刃惊天宗',
                desc = '(消耗两点战技点)\n2秒内无法移动，格挡概率变为100%，格挡时免疫伤害\n如果格挡成功，立刻解除无法移动效果，下一次攻速调高，造成220%的范围伤害。\n如果2秒种并未格挡任何伤害，格挡概率回归初始，下次攻击造成150%的单体伤害。',
                pos = {MID_X, MID_Y},
                group = "curse",
                tags = {"curse"},
                onactivate = function(inst)
                end,
                ondeactivate = function(inst)
                end,
            },
            i26_skill2 = {
                title = '后发先至',
                desc = '(2分钟)啥也不消耗。\n格挡概率变成100%\n如果格挡成功下一次攻击伤害为120%\n主动攻击或者触发格挡后，本技能效果消失',
                pos = {MID_X, MID_Y-lockd-15},
                group = "curse",
                tags = {"curse"},
                onactivate = function(inst)
                end,
                ondeactivate = function(inst)
                end,
            },
            i26_skill3 = {
                title = '闪烁',
                desc = '（持有老铁时）\n在受到伤害时有20%概率格挡\n在格挡成功后，老铁开始发光，下一次攻击会变成范围伤害',
                pos = {MID_X, MID_Y+lockd+18},
                group = "curse",
                tags = {"curse"},
                onactivate = function(inst)
                end,
                ondeactivate = function(inst)
                end,
            },
            i26_skill4 = {
                title = '老铁',
                desc = '\n可以通过将其他近战武器熔铸（就是对着老铁右键）到老铁身上来提升属性。每种近战武器只能熔铸一次。熔铸后，老铁获得原武器一半的攻击属性。每次熔铸都会提供10%的防御提升和1点的位面防御。上限分别是90%，10',
                pos = {MID_X+LIF1, MID_Y+10},
                group = "curse",
                tags = {"curse"},
                onactivate = function(inst)
                end,
                ondeactivate = function(inst)
                end,
            },
            i26_skill5 = {
                title = '飞铗震赫',
                desc = '（消耗一点战技点）\n回复'..TUNING.i26_SKILLR_HEAL..'生命值。\n向鼠标方向冲刺，并在落点出造成150%的范围伤害',
                pos = {MID_X+RIG1, MID_Y+10},
                group = "curse",
                tags = {"curse"},
                onactivate = function(inst)
                end,
                ondeactivate = function(inst)
                end,
            },
        -- 上
            i26_i26_skill6_lock = {
                title = '注意！下一个技能点',
                desc = '需要3点洞察',
                pos = {MID_X, MID_Y+TOP1+10},
                group = "curse",
                tags = {"curse", "lock"},
                lock_open = function(prefabname, activatedskills, readonly)
                    if TheWorld and TheWorld.ismastersim then return true end
                    local skilltreeupdater = ThePlayer and ThePlayer.components.skilltreeupdater or TheSkillTree
                    return skilltreeupdater:GetAvailableSkillPoints(prefabname) >= 3 
                    or skilltreeupdater:IsActivated("i26_skill6", prefabname)
                end,
                connects = {
                    "i26_skill6",
                },
            },
            i26_skill6 = {
                title = '大招强化',
                desc = '大招格挡成功后，有（固定普通格挡概率*50%）的概率恢复一点技能点。',
                cost = 3,
                pos = {MID_X, MID_Y+TOP1+TOP1},
                group = "curse",
                tags = {"curse"},
                onactivate = function(inst)
                    local i26skill = inst.components.i26skill
                    if i26skill then 
                        i26skill.DZ_TA = true
                    end
                end,
                ondeactivate = function(inst)
                    local i26skill = inst.components.i26skill
                    if i26skill then
                        i26skill.DZ_TA = false
                    end
                end,
                connects = {
                    "i26_skill_t2",
                },
            },

            i26_skill_t2 = {
                title = '格挡概率提升',
                desc = '格挡的概率+20%',
                pos = {MID_X, MID_Y+TOP1+TOP1+TOP1},
                group = "curse",
                tags = {"curse"},
                onactivate = function(inst)
                    local i26skill = inst.components.i26skill
                    if i26skill then
                        i26skill.ddc = i26skill.ddc + .2
                    end
                end,
                ondeactivate = function(inst)
                    local i26skill = inst.components.i26skill
                    if i26skill then
                        i26skill.ddc = i26skill.ddc - .2
                    end
                end,
                connects = {
                    "i26_skill_t1","i26_skill_t3",
                },
            },
            i26_skill_t1 = {
                title = '格挡概率提升',
                desc = '格挡概率提高20%\n满血时格挡概率变成0，格挡概率随着生命值降低而提高，在生命值低于50%时提升到正常值',
                pos = {MID_X+LIF1, MID_Y+TOP1+TOP1+TOP1-2},
                group = "curse",
                tags = {"curse"},
                onactivate = function(inst)
                    local i26skill = inst.components.i26skill
                    if i26skill then
                        i26skill.ddc = i26skill.ddc + .2
                        i26skill.DT_DDC = true
                    end
                end,
                ondeactivate = function(inst)
                    local i26skill = inst.components.i26skill
                    if i26skill then
                        i26skill.ddc = i26skill.ddc - .2
                        i26skill.DT_DDC = false
                    end
                end,
            },
            i26_skill_t3 = {
                title = '格挡概率提升',
                desc = '格挡概率+10%',
                pos = {MID_X+RIG1, MID_Y+TOP1+TOP1+TOP1-2},
                group = "curse",
                tags = {"curse"},
                onactivate = function(inst)
                    local i26skill = inst.components.i26skill
                    if i26skill then
                        i26skill.ddc = i26skill.ddc + .1
                    end
                end,
                ondeactivate = function(inst)
                    local i26skill = inst.components.i26skill
                    if i26skill then
                        i26skill.ddc = i26skill.ddc - .1
                    end
                end,
            },
        -- 下
            i26_i26_skill_d1_lock = {
                title = '注意！下一点技能点',
                desc = '需要5点洞察',
                pos = {MID_X, MID_Y+DOW1-30},
                group = "curse",
                tags = {"curse", "lock"},
                lock_open = function(prefabname, activatedskills, readonly)
                    if TheWorld and TheWorld.ismastersim then return true end
                    local skilltreeupdater = ThePlayer and ThePlayer.components.skilltreeupdater or TheSkillTree
                    return skilltreeupdater:GetAvailableSkillPoints(prefabname) >= 5 
                    or skilltreeupdater:IsActivated("i26_skill_d1", prefabname)
                end,
                connects = {
                    "i26_skill_d1",
                },
            },
            i26_skill_d1 = {
                title = '极致的伤害！！',
                desc = "根据已损失的生命上限获得伤害提升。\n对目标的第一次伤害根据目标（生命上限/减伤）高于蟾蜍血量上限的多少来扣除百分比血量上限（两倍达到最高的20%）。云璃的伤害附带0.1%的百分比真实伤害。",
                pos = {MID_X, MID_Y+DOW1+DOW1-20},
                group = "curse",
                tags = {"curse"},
                onactivate = function(inst)
                    -- if inst.components.combat then
                    --     inst.components.combat.externaldamagemultipliers:SetModifier("i26_skill_d1", 2.5)
                    -- end
                    inst.YunLiFM = true
                    -- local i26skill = inst.components.i26skill
                    -- if i26skill then
                    --     i26skill:REBUILD_HPS()
                    -- end
                end,
                ondeactivate = function(inst)
                    -- if inst.components.combat then
                    --     inst.components.combat.externaldamagemultipliers:RemoveModifier("i26_skill_d1")
                    -- end
                    inst.YunLiFM = false
                    -- local i26skill = inst.components.i26skill
                    -- if i26skill then
                    --     i26skill:CANCEL_REBUILD_HPS()
                    -- end
                end,
            },
        -- 左 
            i26_i26_skill_l1_lock = {
                title = '注意！下一点技能点',
                desc = '需要3点洞察',
                pos = {MID_X-20, MID_Y+DOW1-20},
                group = "curse",
                tags = {"curse", "lock"},
                lock_open = function(prefabname, activatedskills, readonly)
                    if TheWorld and TheWorld.ismastersim then return true end
                    local skilltreeupdater = ThePlayer and ThePlayer.components.skilltreeupdater or TheSkillTree
                    return skilltreeupdater:GetAvailableSkillPoints(prefabname) >= 3 
                    or skilltreeupdater:IsActivated("i26_skill_l1", prefabname)
                end,
                connects = {
                    "i26_skill_l1",
                },
            },
            i26_skill_l1 = {
                title = '减少大招消耗',
                desc = '减少一点大招消耗的技能点',
                pos = {MID_X+LIF1+LIF1+20, MID_Y+DOW1+DOW1},
                group = "curse",
                tags = {"curse"},
                onactivate = function(inst)
                    local i26skill = inst.components.i26skill
                    if i26skill then
                        i26skill.rcost = 1
                    end
                end,
                ondeactivate = function(inst)
                    local i26skill = inst.components.i26skill
                    if i26skill then
                        i26skill.rcost = 2
                    end
                end,
                connects = {
                    "i26_skill_l2",
                },
            },
            i26_skill_l2 = {
                title = '提升生命上限',
                desc = '+50生命上限',
                pos = {MID_X+LIF1+LIF1+LIF1+22, MID_Y+DOW1-2},
                group = "curse",
                tags = {"curse"},
                onactivate = function(inst)
                    if inst.components.health then
                        inst.components.health.maxhealth = inst.components.health.maxhealth + 50
                        inst.components.health:DoDelta(0, true)
                    end
                end,
                ondeactivate = function(inst)
                    if inst.components.health then
                        inst.components.health.maxhealth = math.max(inst.components.health.maxhealth - 50, 1)
                        inst.components.health:DoDelta(0, true)
                    end
                end,
                connects = {
                    "i26_skill_l3",
                },
            },
            i26_skill_l3 = {
                title = '大招强化',
                desc = '大招格挡之后，若玩家不行动，不会打断大招100%格挡效果。',
                pos = {MID_X+LIF1+LIF1+LIF1+LIF1+24, MID_Y-6},
                group = "curse",
                tags = {"curse"},
                onactivate = function(inst)
                    local i26skill = inst.components.i26skill
                    if i26skill then
                        i26skill.DD_TOPER = true
                    end
                end,
                ondeactivate = function(inst)
                    local i26skill = inst.components.i26skill
                    if i26skill then
                        i26skill.DD_TOPER = false
                    end
                end,
                connects = {
                    "i26_skill_l4",
                },
            },
            i26_skill_l4 = {
                title = '战技点消耗减少',
                desc = '增加100%制作战技点消耗；\n战斗时，失去被动回血的效果。飞r恢复血量变为30。\n如果老铁在投掷过程中造成了伤害，则飞r在使用后恢复一战技点。',
                pos = {MID_X+LIF1+LIF1+LIF1+26, MID_Y+TOP1-4},
                group = "curse",
                tags = {"curse"},
                onactivate = function(inst)
                    inst:RemoveTag("i26build1")
                    inst:AddTag("i26build2")
                    local i26skill = inst.components.i26skill
                    if i26skill then
                        i26skill.TOPTER = true
                    end
                end,
                ondeactivate = function(inst)
                    inst:RemoveTag("i26build2")
                    inst:AddTag("i26build1")
                    local i26skill = inst.components.i26skill
                    if i26skill then
                        i26skill.TOPTER = false
                    end
                end,
            },
        -- 右
            i26_i26_skill_r1_lock = {
                title = '注意！下一点技能点',
                desc = '需要3点洞察',
                pos = {MID_X+20, MID_Y+DOW1-20},
                group = "curse",
                tags = {"curse", "lock"},
                lock_open = function(prefabname, activatedskills, readonly)
                    if TheWorld and TheWorld.ismastersim then return true end
                    local skilltreeupdater = ThePlayer and ThePlayer.components.skilltreeupdater or TheSkillTree
                    return skilltreeupdater:GetAvailableSkillPoints(prefabname) >= 3 
                    or skilltreeupdater:IsActivated("i26_skill_r1", prefabname)
                end,
                connects = {
                    "i26_skill_r1",
                },
            },
            i26_skill_r1 = {
                title = '防御提升',
                desc = '+10%伤害减免\n格挡时的伤害减免+20%',
                pos = {MID_X+RIG1+RIG1-20, MID_Y+DOW1+DOW1},
                group = "curse",
                tags = {"curse"},
                onactivate = function(inst)
                    local i26skill = inst.components.i26skill
                    if i26skill then
                        i26skill.dd_p = i26skill.dd_p - .2
                    end
                    local health = inst.components.health 
                    if health then
                        health.externalabsorbmodifiers:SetModifier("i26_skill_r1", .1)
                    end
                end,
                ondeactivate = function(inst)
                    local i26skill = inst.components.i26skill
                    if i26skill then
                        i26skill.dd_p = i26skill.dd_p + .2
                    end
                    local health = inst.components.health 
                    if health then
                        health.externalabsorbmodifiers:SetModifier("i26_skill_r1", 0)
                    end
                end,
                connects = {
                    "i26_skill_r2",
                },
            },
            i26_skill_r2 = {
                title = '伤害减免提升',
                desc = '+10%伤害减免',
                pos = {MID_X+RIG1+RIG1+RIG1-22, MID_Y+DOW1-2},
                group = "curse",
                tags = {"curse"},
                onactivate = function(inst)
                    local health = inst.components.health 
                    if health then
                        health.externalabsorbmodifiers:SetModifier("i26_skill_r2", .1)
                    end
                end,
                ondeactivate = function(inst)
                    local health = inst.components.health 
                    if health then
                        health.externalabsorbmodifiers:SetModifier("i26_skill_r2", 0)
                    end
                end,
                connects = {
                    "i26_skill_r3",
                },
            },
            i26_skill_r3 = {
                title = '大大提升生命上限',
                desc = '+100生命上限',
                pos = {MID_X+RIG1+RIG1+RIG1+RIG1-24, MID_Y+TOP1+DOW1-6},
                group = "curse",
                tags = {"curse"},
                onactivate = function(inst)
                    if inst.components.health then
                        inst.components.health.maxhealth = inst.components.health.maxhealth + 100
                        inst.components.health:DoDelta(0, true)
                    end
                end,
                ondeactivate = function(inst)
                    if inst.components.health then
                        inst.components.health.maxhealth = math.max(inst.components.health.maxhealth - 100, 1)
                        inst.components.health:DoDelta(0, true)
                    end
                end,
                connects = {
                    "i26_skill_r4",
                },
            },
            i26_skill_r4 = {
                title = '伤害减免提升',
                desc = '降低云璃50%伤害。\n限制云璃单次受到的伤害不可高于生命上限的5%。\n一秒内受到的伤害不可高于云璃生命上限的50%。',
                pos = {MID_X+RIG1+RIG1+RIG1-26, MID_Y+TOP1+TOP1+DOW1-4},
                group = "curse",
                tags = {"curse"},
                onactivate = function(inst)
                    if inst.components.combat then
                        inst.components.combat.damagemultiplier = .5
                    end
                    if inst.components.health then
                        inst.components.health.i26limi = true
                    end
                end,
                ondeactivate = function(inst)
                    if inst.components.combat then
                        inst.components.combat.damagemultiplier = 1
                    end
                    if inst.components.health then
                        inst.components.health.i26limi = false
                    end
                end,
            },
        -- 
    }

    for name, data in pairs(skills) do
        -- If it's not a lock.
        if not data.lock_open then
            if not data.icon then
                data.icon = name
            end
        end
    end

    return {
        SKILLS = skills,
        ORDERS = ORDERS
    }
end

return BuildSkillsData